﻿#include <iostream>

class Base {
public:
    virtual void PrintTestA()
    {
        printf("Base Test A\n");
    }

    virtual void PrintTestB()
    {
        printf("Base Test B\n");
    }

protected:
    int32_t protectVar = 1;

private:
    int32_t priVar = 2;
};


class Child : public Base {
public:
    virtual void PrintTestB()
    {
        printf("Child Test B\n");
    }

private:
    int32_t childVar = 3;
};


int main()
{
    Child child;
    Base* pBase = &child;
    pBase->PrintTestA();
    pBase->PrintTestB();

    printf("\npBase addr: 0x%x\n", pBase);

    int32_t* mem = (int32_t*)pBase;
    printf("memory: 0x%x 0x%x 0x%x 0x%x\n",
        mem[0], mem[1], mem[2], mem[3]);

    int32_t* pVt = (int32_t*)mem[0];
    printf("vtable [0]: 0x%x [1]: 0x%x\n\n",
        pVt[0], pVt[1]);

    Base base = (Base)child;
    base.PrintTestA();
    base.PrintTestB();

    (*pBase).PrintTestB();
}

